package com.example.com.skills_utf8;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;

import com.app.util.Utils;
import com.app.util.Utils_Dialog;
import com.app.util.Utils_HEX;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.security.MessageDigest;


public class _67Activity extends Activity implements View.OnClickListener{

    _67Activity activity = this;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity__67);


        init();

    }


    void init(){

        Button btn_change_tabs = (Button)findViewById(R.id.btn_change_tabs);
        Button btn_invoke_remote_service = (Button)findViewById(R.id.btn_invoke_remote_service);
        Button btn_copy_assetfile = (Button)findViewById(R.id.btn_copy_assetfile);
        btn_copy_assetfile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try {
                    File file_dest = new File(Environment.getExternalStorageDirectory(), "0019.jpg");

                    InputStream is = getAssets().open("0019.jpg");
                    Utils.CopyFileFromStream(file_dest, is);

                    is = getAssets().open("0019.jpg");
                    String str = Utils.getMd5ByFile(file_dest);
                    String str1 = Utils.getMd5ByFile(is);


                    Utils_Dialog.ShowTips(activity, str + "--" + str1 + " 比较结果 " + str.equals(str1));

                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        });


        btn_change_tabs.setOnClickListener(this);
        btn_invoke_remote_service.setOnClickListener(this);

    }






    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        Fragment fragment = null;

        switch(v.getId()){

            case R.id.btn_change_tabs:
                fragment = new _67Fragment();
                break;
            case R.id.btn_invoke_remote_service:
                fragment = new _67_2Fragment();
                break;


        }

        if(fragment != null){
            android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.replace(R.id.layout_content, fragment);
            transaction.commit();
        }



    }


}
